package com.example.wallpaperapp.p;

import com.example.wallpaperapp.m.LoginM;
import com.example.wallpaperapp.m.LoginModel;
import com.example.wallpaperapp.ui.activity.LoginActivity;
import com.example.wallpaperapp.v.LoginV;

/**
 * @Package: com.example.wallpaperapp.p
 * @ClassName: LoginPresent
 * @Description: java类作用描述
 * @Author: zrmo
 * @CreateDate: 2020/11/14 15:43
 */
public class LoginPresent implements LoginP {
    LoginV login ;
    LoginM loginM = new LoginModel();
    public LoginPresent(LoginV loginv) {
        login = loginv;
    }
    @Override
    public void requestMsg() {
        int   userName=login.getUserName();
        String   password=login.getPassword();
        if (userName==0) {
            login.onFailed("用户名不能为空");
        } else if (password.equals("")) {
            login.onFailed("密码不能为空");
        }else {
            loginM.requestMsg(userName, password, new LoginM.callBack() {
                @Override
                public void onSuccess(int msg) {
                    login.result(msg);
                    login.onSuccess("登录成功");
                }
                @Override
                public void onFailed(String msg) {
                    login.onFailed(msg);
                }
            });
        }
    }

}
